package service

import (
	"github.com/gofiber/fiber/v2"
	"guns-excel/internal/app/model"
	"guns-excel/internal/app/repository"
	"guns-excel/internal/pkg/database"
	"guns-excel/internal/pkg/util"
	"time"
)

func AddRule(ctx *fiber.Ctx, rule *model.Rule) error {
	rule.Id = util.GetId()
	nowDate := time.Now()
	rule.CreatedOn = &nowDate
	return repository.AddRule(ctx, rule, database.MysqlDB)
}

func GetRuleByModelExcelId(ctx *fiber.Ctx, modelExcelId string) (*model.Rule, error) {
	return repository.GetRuleByModelExcelId(ctx, modelExcelId, database.MysqlDB)
}
